package com.cwz.core.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.cwz.core.utils.string.StringUtils;

/**
 * @program: w-demo
 * @description: 切库上下文工具类
 * @author: Wen
 **/
public class DataSourceContextHolder {
	private static final TransmittableThreadLocal<String> THREAD_LOCAL = new TransmittableThreadLocal<>();

	public static void set(String company) {
		THREAD_LOCAL.set("null".equals(company) ? null : company);
	}

	public static String get() {
		String company = THREAD_LOCAL.get();
		return StringUtils.isNotBlank(company) && !"null".equals(company) ? company : null;
	}

	public static void remove() {
		THREAD_LOCAL.remove();
	}
}
